package com.ruoyi.web.controller.drugs;


import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.drugs.domain.Dramaintain;
import com.ruoyi.drugs.service.IDruDrmaintainService;
import com.ruoyi.system.domain.SysCheck;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;


import java.util.List;



@RestController
@RequestMapping("/drugs/drmaintain")
public class DruDrmaintainController extends BaseController {
    @Autowired
    private IDruDrmaintainService service;
    /**
     * 获取检查费用列表
     */
    @PreAuthorize("@ss.hasPermi('drugs:drmaintain:list')")
    @GetMapping("/list")
    public TableDataInfo list(Dramaintain dramaintain)
    {
        startPage();
        List<Dramaintain> list = service.selectDrmaintainList(dramaintain);
        return getDataTable(list);
    }
    /**
     * 新增检查项目
     */
    @PreAuthorize("@ss.hasPermi('drugs:drmaintain:add')")
    @Log(title = "检查费用", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@Validated @RequestBody Dramaintain dramaintain)
    {
        dramaintain.setCreateBy(getUsername());
        return toAjax(service.insertDrmaintain(dramaintain));
    }

    /**
     * 修改检查项目
     */
    @PreAuthorize("@ss.hasPermi('drugs:drmaintain:edit')")
    @Log(title = "检查费用", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@Validated @RequestBody Dramaintain dramaintain)
    {
        dramaintain.setUpdateBy(getUsername());
        return toAjax(service.updateDrmaintain(dramaintain));
    }

    /**
     * 根据编号获取详细信息
     */
    @PreAuthorize("@ss.hasPermi('drugs:drmaintain:query')")
    @GetMapping(value = "/{drmId}")
    public AjaxResult getInfo(@PathVariable Long drmId)
    {
        return success(service.selectDrmaintainById(drmId));
    }

    /**
     * 删除检查信息
     */
    @PreAuthorize("@ss.hasPermi('drugs:drmaintain:remove')")
    @Log(title = "检查信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{drmIds}")
    public AjaxResult remove(@PathVariable Long[] drmIds)
    {
        return toAjax(service.deleteDrmaintainByIds(drmIds));
    }

    /**
     * 根据状态修改药品
     */
    @PreAuthorize("@ss.hasPermi('drugs:drmaintain:edits')")
    @Log(title = "药品信息", businessType = BusinessType.UPDATE)
    @PutMapping("/list/{drmIds}")
    public AjaxResult edits(@PathVariable Long[] drmIds)
    {
        return toAjax(service.updateDrmaintains(drmIds));
    }

    /**
     * 根据状态删除药品
     */
    @PreAuthorize("@ss.hasPermi('drugs:removes:edits')")
    @Log(title = "药品信息", businessType = BusinessType.UPDATE)
    @PutMapping("/removes/{drmIds}")
    public AjaxResult removes(@PathVariable Long[] drmIds)
    {
        return toAjax(service.updateDrmaintainss(drmIds));
    }
}

